package com.compty.paint.manager;

import java.util.List;

import com.compty.core.hibernate.HibernateEntityDao;
import com.compty.paint.domain.Advertisement;
import com.compty.paint.domain.SpecialSubject;

public class SpecialSubjectManager extends HibernateEntityDao<SpecialSubject>{
	
	private AdvertisementManager advertisementManager;
	
	public SpecialSubject findByPainterId(Long painterID){
		
		String hql = " from SpecialSubject where painterID = ?";
		
		return super.findUnique(hql, painterID);
	}
	
	public void removeById(Integer id){
		super.removeById(id);
		List<Advertisement> list = advertisementManager.findBy("specialSubjectID", id);
		advertisementManager.removeAll(list);
	}

	public void setAdvertisementManager(AdvertisementManager advertisementManager) {
		this.advertisementManager = advertisementManager;
	}

}
